package cn.edu.nsmc.modules.sys.controller;

import cn.edu.nsmc.common.utils.R;
import cn.edu.nsmc.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.io.IOException;

@RestController
@RequestMapping("/sys/file")
public class SysFileController {
    @Autowired
    private FileUtils fileUtils;
    @GetMapping("/getFile")
    public void getFile(String filename, HttpServletResponse response) throws IOException {
        fileUtils.getFile(filename, response);
    }
    @PostMapping("/addFile")
//    @RequiresPermissions("sys:log:list")
    public R addFile(@RequestParam("file") MultipartFile file) throws FileNotFoundException {
        return fileUtils.addFile(file);
    }
}
